using System.Collections.ObjectModel;

namespace Game.ExtensibleObjects
{
    public class RuntimeExtensionCollection : ObservableCollection<IRuntimeExtension>
    {
        protected override void InsertItem(int index, IRuntimeExtension item)
        {
            if (!Contains(item))
            {
                base.InsertItem(index, item);
            }
        }

        public T Find<T>()
        {
            foreach (var e in this)
            {
                if (e is T)
                {
                    return (T)e;
                }
            }

            return default(T);
        }

    }
}